package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SignLog;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISignLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 签章日志Controller
 * 
 * @author ess
 * @date 2021-10-28
 */
@RestController
@RequestMapping("/system/signLog")
public class SignLogController extends BaseController
{
    @Autowired
    private ISignLogService signLogService;

    /**
     * 查询签章日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SignLog signLog)
    {
        startPage();
        List<SignLog> list = signLogService.selectSignLogList(signLog);
        return getDataTable(list);
    }

    /**
     * 导出签章日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:export')")
    @Log(title = "签章日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SignLog signLog)
    {
        List<SignLog> list = signLogService.selectSignLogList(signLog);
        ExcelUtil<SignLog> util = new ExcelUtil<SignLog>(SignLog.class);
        return util.exportExcel(list, "签章日志数据");
    }

    /**
     * 获取签章日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:query')")
    @GetMapping(value = "/{signLogId}")
    public AjaxResult getInfo(@PathVariable("signLogId") String signLogId)
    {
        return AjaxResult.success(signLogService.selectSignLogBySignLogId(signLogId));
    }

    /**
     * 新增签章日志
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:add')")
    @Log(title = "签章日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignLog signLog)
    {
        return toAjax(signLogService.insertSignLog(signLog));
    }

    /**
     * 修改签章日志
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:edit')")
    @Log(title = "签章日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignLog signLog)
    {
        return toAjax(signLogService.updateSignLog(signLog));
    }

    /**
     * 删除签章日志
     */
    @PreAuthorize("@ss.hasPermi('system:signLog:remove')")
    @Log(title = "签章日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{signLogIds}")
    public AjaxResult remove(@PathVariable String[] signLogIds)
    {
        return toAjax(signLogService.deleteSignLogBySignLogIds(signLogIds));
    }
}
